<template>
	<view class="p-10">
		<view class="card">
			<my-forms ref="valiForm" :model="valiFormData" :label-position="'top'" :formItem="formData"></my-forms>
			<u-button type="primary" shape="circle" text="提交" @click="submit"></u-button>
		</view>
	</view>
</template>
<script setup>
	import {
		reactive,
		ref,
		unref
	} from 'vue'
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	import {
		postDestroy
	} from '@/api/hidden-danger.js'
	// 校验表单数据
	const formData = ref([{
		type: 'textarea',
		label: '销号意见',
		required: true,
		prop: 'accetpMessage'
	}])
	const valiForm = ref(null)
	const valiFormData = reactive({})
	// 保存提交
	const submit = () => {
		valiForm.value.$refs.refMyForm.validate().then(async (res) => {
			const {
				code
			} = await postDestroy({
				checkPlanIds: [unref(id)],
				...unref(valiFormData)
			})
			if (code == 200) {
				uni.showToast({
					title: `销号成功`,
					success() {
						uni.navigateBack({
							delta: 2
						})
					}
				})
			}
		}).catch(err => {
			console.log('err', err);
		})
	}
	let id = ref()
	onLoad((e) => {
		id.value = e.id
	})
</script>
<style lang="scss" scoped>
</style>